]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
overviewControls: Simplify DashSpacer
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Fri, 27 Nov 2020 14:07:03 +0000 (11:07 -0300)
committerMarge Bot <marge-bot@gnome.org>
Wed, 2 Dec 2020 22:43:04 +0000 (22:43 +0000)
Make it subclass ClutterActor, since we don't need any of StWidget's
features. Pass the source actor of the bind constraint in the
constructor, and remove the extra method to set the source actor.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1518>

js/ui/overviewControls.js

index 3d313e7d40446733c5b4874b9c42d8bc441ecb02..9d18d82f8911279f7159e75026bb0c62b351bfab 100644 (file)
@@ -361,24 +361,15 @@ class DashSlider extends SlidingControl {
 });
 
 var DashSpacer = GObject.registerClass(
-class DashSpacer extends St.Widget {
-    _init(params) {
-        super._init(params);
-
-        this._bindConstraint = null;
-    }
+class DashSpacer extends Clutter.Actor {
+    _init(source) {
+        super._init();
 
-    setDashActor(dashActor) {
-        if (this._bindConstraint) {
-            this.remove_constraint(this._bindConstraint);
-            this._bindConstraint = null;
-        }
-
-        if (dashActor) {
-            this._bindConstraint = new Clutter.BindConstraint({ source: dashActor,
-                                                                coordinate: Clutter.BindCoordinate.SIZE });
-            this.add_constraint(this._bindConstraint);
-        }
+        this._bindConstraint = new Clutter.BindConstraint({
+            source,
+            coordinate: Clutter.BindCoordinate.SIZE,
+        });
+        this.add_constraint(this._bindConstraint);
     }
 
     vfunc_get_preferred_width(forHeight) {
@@ -406,8 +397,7 @@ class ControlsManager extends St.Widget {
 
         this.dash = new Dash.Dash();
         this._dashSlider = new DashSlider(this.dash);
-        this._dashSpacer = new DashSpacer();
-        this._dashSpacer.setDashActor(this._dashSlider);
+        this._dashSpacer = new DashSpacer(this._dashSlider);
 
         let workspaceManager = global.workspace_manager;
         let activeWorkspaceIndex = workspaceManager.get_active_workspace_index();